/**
* @file    hi_hal_uartmsg_conf.h
* @brief   uart message struct and interface declaration
*
* Copyright (C), 2016-2019, Hisilicon Tech. Co., Ltd.
*
* @author    IP Camera Reference Develop Team
* @date       2018/12/11
* @version   1.0

*/



#ifndef __HI_HAL_UARTMSG_CONF_H__
#define __HI_HAL_UARTMSG_CONF_H__


#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <pthread.h>
#include <sys/prctl.h>
#include <linux/completion.h>
#include "shell.h"
#include "sys/time.h"
#include "sys/prctl.h"
#include "asm/io.h"
#include "los_mux.h"
#include "los_task.h"
#include "los_sem.h"
#include "hisoc/uart.h"
#include "uart.h"
#include "pm/hi_type.h"
#include "hi_appcomm.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */


HI_S32 HI_UARTMSG_Dprintf( char* pszfmt, ...);

#define HI_UARTMSG_MAX_CALLBACK_NUM     (8)

#define UARTMSG_MSGDATA_HEAD (0x7B)
#define UF_START 0
#define UF_LEN 1
#define UF_CMD 2
#define UF_DATA 3
#define UF_COMM_DATA_LEN 6
#define UF_MAX_LEN 128
#define UF_MIN_LEN 4
#define UART2_BUF_LEN   1024


#define UART_BAUDRATE 115200



#if 0
#define CFG_DEBUG_MLOG_ON
#ifdef  CFG_DEBUG_MLOG_ON
/** unified log macro define */
#define MLOGE(fmt, args...)  HI_UARTMSG_Dprintf("File:<%s> Fun:[%s] Line:%d\n "fmt, __FILE__, __FUNCTION__, __LINE__, ##args)
#define MLOGW(fmt, args...)  HI_UARTMSG_Dprintf(fmt, ##args)
#define MLOGD(fmt, args...)  HI_UARTMSG_Dprintf(fmt, ##args)
#else
#define MLOGE(fmt, args...)
#define MLOGW(fmt, args...)
#define MLOGD(fmt, args...)
#endif
#endif




#define HI_UARTMSGCHECK_POINTER(p ,x) \
    do { if (!(p)) { \
            MLOGE("null pointer\n");\
            return x; \
        } }while(0)



#define HI_UARTMSGCHECK_EXPR(expr, x) \
    do{ \
        if (!(expr)){   \
            MLOGE(" expr[%s] false\n", #expr); \
            return x;  \
        }   \
    }while(0)







#ifndef HI_NULL
#define HI_NULL     0L
#endif

#ifndef  HI_SUCCESS
#define HI_SUCCESS  0
#endif

#ifndef HI_FAILURE
#define HI_FAILURE  (-1)
#endif


#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

#endif /* __HI_HAL_UARTMSG_CONF_H__ */
